﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="Admin_Modules_Posts_Default" %>

<%@ Register TagPrefix="avg" Namespace="Avg.Controls" Assembly="SmartPager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="c" runat="Server">
    <script src="/Admin/Modules/Menu/js/Menuedit.js" type="text/javascript"></script>
    <input type="hidden" id="hdfPostType" value="post" />
    <div id="col-container">
        <div>
            <div class="col-wrap">
                <div style='vertical-align: text-top'>
                    <div class="tablenav top">
                        <fieldset>
                            <legend>Search</legend>
                            <div class="alignleft actions">
                                <asp:DropDownList ID="ddlTermTaxonomy" runat="server" AppendDataBoundItems="true">
                                    <asp:ListItem Value="-1">---- All Categories----</asp:ListItem>
                                </asp:DropDownList>
                                &nbsp;&nbsp;&nbsp;&nbsp; Key word :
                                <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>&nbsp;&nbsp;&nbsp;&nbsp;
                                <asp:Button ID="btnSeach" runat="server" Text="Search" 
                                    CssClass="button-secondary action" onclick="btnSeach_Click" />
                            </div>
                        </fieldset>
                        <div class="alignleft actions">
                            <select name="action">
                                <option value="-1" selected="selected">Bulk Actions</option>
                                <option value="delete">Delete</option>
                            </select>
                            <input type="button" name="" id="doaction" class="button-secondary action" value="Apply" />
                        </div>
                        <div class="tablenav-pages">
                            <avg:SmartPager ID="smartPager" runat="server" Visible="false" />
                            <br />
                        </div>
                        <br class="clear" />
                    </div>
                    <table class="wp-list-table widefat fixed tags" cellspacing="0">
                        <thead>
                            <tr>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="">
                                    <input type="checkbox" id="selectall" />
                                </th>
                                <th scope="col" id="Th1" class="manage-column column-name sortable desc" style="">
                                    <a href="#"><span>Image</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="name" class="manage-column column-name sortable desc" style="">
                                    <a href="#"><span>Name</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="description" class="manage-column column-description sortable desc"
                                    style="">
                                    <a href="#"><span>Categories</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="slug" class="manage-column column-slug sortable desc" style="">
                                    <a href="#"><span>Post Tags</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="posts" class="manage-column column-posts num sortable desc" style="">
                                    <a href="#"><span>Count</span><span class="sorting-indicator"></span></a>
                                </th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th scope="col" id="Th2" class="manage-column column-cb check-column" style="">
                                    <input type="checkbox" id="Checkbox1" />
                                </th>
                                <th scope="col" id="Th3" class="manage-column column-name sortable desc" style="">
                                    <a href="#"><span>Image</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="Th4" class="manage-column column-name sortable desc" style="">
                                    <a href="#"><span>Name</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="Th5" class="manage-column column-description sortable desc" style="">
                                    <a href="#"><span>Post Tags</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="Th6" class="manage-column column-slug sortable desc" style="">
                                    <a href="#"><span>Categories</span><span class="sorting-indicator"></span></a>
                                </th>
                                <th scope="col" id="Th7" class="manage-column column-posts num sortable desc" style="">
                                    <a href="#"><span>Count</span><span class="sorting-indicator"></span></a>
                                </th>
                            </tr>
                        </tfoot>
                        <tbody id="the-list" class="list:tag">
                            <asp:Repeater ID="rpt" runat="server">
                                <ItemTemplate>
                                    <tr id="tag-<%#Eval("Id") %>">
                                        <th scope="row" class="check-column">
                                            <input type="checkbox" name="delete_tags" value="<%#Eval("Id") %>">
                                        </th>
                                        <td class="slug column-slug">
                                            <img src='<%#UrlBuilder.GetImage(Eval("ImageUrl").ToString(),100,100,true) %>' alt=''  style='width: 100px; height: 100px;' />
                                            <div class="row-actions">
                                                <span class="edit"><a href="/Admin/Modules/Posts/PostEdit.aspx?Id=<%#Eval("Id") %>">
                                                    Edit</a> | </span><span class="delete"><a class="delete-tag" href="#<%#Eval("Id") %>">
                                                        Delete</a></span>
                                            </div>
                                        </td>
                                        <td class="name column-name">
                                            <strong><a class="row-title" href="/Admin/Modules/Posts/PostEdit.aspx?Id=<%#Eval("Id") %>" title="Edit “<%#Eval("Title") %>”">
                                                <%#Eval("Title")%></a></strong><br><%#FormatString.DateTimeToString(Eval("CreatedDate").ToString()) %>
                                            <div class="row-actions">
                                                <span class="edit"><a href="/Admin/Modules/Posts/PostEdit.aspx?Id=<%#Eval("Id") %>">
                                                    Edit</a> | </span><span class="delete"><a class="delete-tag" href="#<%#Eval("Id") %>">
                                                        Delete</a></span>
                                            </div>
                                        </td>
                                        <td class="description column-description">
                                            <%#Wp.BLL.TblTermRelationshipsManager.CreateInstant().GetStringTagsList(int.Parse(Eval("Id").ToString()), "posttags") %>
                                        </td>
                                        <td class="slug column-slug">
                                            <%#Wp.BLL.TblTermRelationshipsManager.CreateInstant().GetStringTagsList(int.Parse(Eval("Id").ToString()), "category")%>
                                        </td>
                                        <td class="posts column-posts"> <%#Eval("NumView")%>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <AlternatingItemTemplate>
                                    <tr id="tag-<%#Eval("Id") %>" class="alternate">
                                        <th scope="row" class="check-column">
                                            <input type="checkbox" name="delete_tags" value="<%#Eval("Id") %>">
                                        </th>
                                        <td class="slug column-slug">
                                            <img src='<%#UrlBuilder.GetImage(Eval("ImageUrl").ToString(),100,100,true) %>' alt='' style='width: 100px; height: 100px;' />
                                            <div class="row-actions">
                                                <span class="edit"><a href="/Admin/Modules/Posts/PostEdit.aspx?Id=<%#Eval("Id") %>">
                                                    Edit</a> | </span><span class="delete"><a class="delete-tag" href="#<%#Eval("Id") %>">
                                                        Delete</a></span>
                                            </div>
                                        </td>
                                        <td class="name column-name">
                                            <strong><a class="row-title" href="/Admin/Modules/Posts/PostEdit.aspx?Id=<%#Eval("Id") %>" title="Edit “<%#Eval("Title") %>”">
                                                <%#Eval("Title")%></a></strong><br/><%#FormatString.DateTimeToString(Eval("CreatedDate").ToString()) %>
                                            <div class="row-actions">
                                                <span class="edit"><a href="/Admin/Modules/Posts/PostEdit.aspx?Id=<%#Eval("Id") %>">
                                                    Edit</a> | </span><span class="delete"><a class="delete-tag" href="#<%#Eval("Id") %>">
                                                        Delete</a></span>
                                            </div>
                                        </td>
                                        <td class="description column-description">
                                            <%#Wp.BLL.TblTermRelationshipsManager.CreateInstant().GetStringTagsList(int.Parse(Eval("Id").ToString()), "posttags") %>
                                        </td>
                                        <td class="slug column-slug">
                                            <%#Wp.BLL.TblTermRelationshipsManager.CreateInstant().GetStringTagsList(int.Parse(Eval("Id").ToString()), "category")%>
                                        </td>
                                        <td class="posts column-posts"> <%#Eval("NumView")%>
                                        </td>
                                    </tr>
                                </AlternatingItemTemplate>
                            </asp:Repeater>
                        </tbody>
                    </table>
                    <div class="tablenav bottom">
                        <div class="alignleft actions">
                            <select name="action2">
                                <option value="-1" selected="selected">Bulk Actions</option>
                                <option value="delete">Delete</option>
                            </select>
                            <input type="button" name="" id="doaction2" class="button-secondary action" value="Apply" />
                        </div>
                        <div class="tablenav-pages">
                            <avg:SmartPager ID="smartPager1" runat="server" Visible="false" />
                        </div>
                        <br class="clear" />
                    </div>
                    <br class="clear" />
                </div>
                <div class="form-wrap">
                    <p>
                        <strong>Note:</strong><br>
                        Deleting a category does not delete the posts in that category. Instead, posts that
                        were only assigned to the deleted category are set to the category <strong>Tin Tức</strong>.
                    </p>
                    <p>
                        Categories can be selectively converted to tags using the <a href="import.php">category
                            to tag converter</a>.
                    </p>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var myMenu = new Menu();
        $("#selectall,#selectall2").change(function () {
            if ($(this).attr("checked") == 'checked') {
                $("input[name=delete_tags]").attr("checked", "checked");
            }
            else {
                $("input[name=delete_tags]").removeAttr("checked");
            }
        });
        $("input[name=delete_tags]").change(function () {
            if ($(this).attr("checked") != 'checked') {
                $("#selectall").removeAttr("checked");
                $("#selectall2").removeAttr("checked");
            }
            else {
                if ($("input[name=delete_tags]").length == $("input[name=delete_tags]:checked").length) {
                    $("#selectall").attr("checked", "checked");
                    $("#selectall2").attr("checked", "checked");
                }
            }
        });

        $("#doaction").click(function () {
            if ($('select[name=action] option:selected').val() == 'delete') {
                var list = $("input[name=delete_tags]:checked");
                var str = '';
                if (confirm('Are you sure to delete')) {
                    $(list).each(function () {
                        var Id = $(this).val();
                        var Id2 = myMenu.DeleteMenu(Id);
                        if (Id2 == -1) {
                            alert("Error!");
                        }
                        $('#tag-' + Id).remove();
                    });
                }
            }
        });
        $("#doaction2").click(function () {
            if ($('select[name=action2] option:selected').val() == 'delete') {
                var list = $("input[name=delete_tags]:checked");
                var str = '';
                if (confirm('Are you sure to delete')) {
                    $(list).each(function () {
                        var Id = $(this).val();
                        var Id2 = myMenu.DeleteMenu(Id);
                        if (Id2 == -1) {
                            alert("Error!");
                        }
                        $('#tag-' + Id).remove();
                    });
                }
            }
        });

        $(".delete-tag").click(function () {
            if (confirm('Are you sure to delete')) {
                var Id = $(this).attr("href").replace("#", "");
                var Id2 = myMenu.DeleteMenu(Id);
                if (Id2 == -1) {
                    alert("Error!");
                }
                $('#tag-' + Id).remove();
            }
        });

    </script>
</asp:Content>
